home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / GXEdit Library & Doc / GXEditDoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  10.3 KB  |  348 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:            GXEditDoc.h
  3.     
  4.     Contains:
  5.     
  6.     Written by:    Barton R. House
  7.     
  8.     Copyright:    © 1993 by Apple Computer, Inc., All rights reserved.
  9.     
  10. */
  11.  
  12. #ifndef _H_Doc
  13. #define    _H_Doc
  14.  
  15. #ifndef __PRINTINGMANAGER__
  16.     #include <PrintingManager.h>
  17. #endif
  18.  
  19. #ifndef graphicsTypesIncludes
  20.     #include "graphics types.h"
  21. #endif
  22.  
  23. #ifndef fontTypesIncludes
  24.     #include "font types.h"
  25. #endif
  26.  
  27. #ifndef layoutTypesIncludes
  28.     #include "layout types.h"
  29. #endif
  30.  
  31. #define kDefaultSize            24
  32. #define kDefaultFace            0        /* no defined constant for plain text */
  33.  
  34. #define kDefaultHeight            18
  35.  
  36. #define kDefaultFont            0
  37. #define kDefaultFontName        "\pMonaco"
  38.  
  39. #define kDefaultStyle            0
  40.  
  41. #define     kGXEditFileVersion0        0x00010000
  42. #define    kGXEditFileVersion        0x00010001
  43. #define    kGXEditMagic            0xabcd1234
  44.  
  45. #define kUndefinedStyle            -1
  46. #define    kUndefinedSize            -1
  47. #define    kUndefinedFont            -1
  48.  
  49. #define kPrintTopMargin            (72 * 1.0)
  50. #define kPrintLeftMargin        (72 * 1.0)
  51. #define kPrintRightMargin        (72 * 1.0)
  52. #define kPrintBottomMargin        (72 * 1.0)
  53.  
  54. /* offset types for GetOffset routines */
  55.  
  56. #define kPreviousOffset            0
  57. #define kVisualLeftOffset            1
  58. #define kVisualRightOffset        2
  59. #define kUpOffset                3
  60. #define kDownOffset                5
  61.  
  62. typedef struct {
  63.  
  64.     gxStyle                textStyle;
  65.     gxFont                textFont;
  66.     short                textSize;
  67.     gxFontScript            script;
  68.     gxFontLanguage            language;
  69.     gxFontPlatform            platform;
  70.     
  71.     short                refCount;            /* how many runs reference this style */
  72.     
  73. } StyleRec, * StylePtr, ** StyleHan;
  74.  
  75. typedef struct {
  76.  
  77.     short                styleIndex;        /* the gxStyle for this run */
  78.     short                paraOffset;        /* offset in the para of first glyph */
  79.     
  80.     short                numText;            /* the amount of text in the run */
  81.     void                    ** text;            /* the text data */
  82.                 
  83. } NewRunRec, * NewRunPtr, ** NewRunHan;
  84.  
  85. typedef struct {
  86.  
  87.     void                    * layout;            /* the layout for the gxLine */
  88.     gxPoint                layoutPos;
  89.     short                height;            /* height of this gxLine */
  90.     
  91.     Boolean                dirty;            /* this gxLine is dirty
  92.                                                 a) layout needs to be calculated -and/or-
  93.                                                 b) height is invalid
  94.                                         */
  95.     
  96.     short                ascent;
  97.     short                descent;
  98.  
  99.     short                start;            /* where this gxLine starts in the paragraph */
  100.  
  101.     short                paraOffset;        /* the paragraph offset of the first glyph */
  102.     short                numText;            /* number of glyphs in this gxLine */
  103.  
  104.     Boolean                reflow;            /* the gxLine has to be reflowed */
  105.                                             
  106.     Boolean                drawn;            /* this gxLine has been drawn and is upto date */
  107.     Boolean                selected;            /* the gxLine selection range is drawn and up to date */
  108.     short                startOffset;        /* the start offset of the selection */
  109.     short                endOffset;            /* the end offset of the selection */
  110.     
  111. } LineRec, * LinePtr, ** LineHan;
  112.  
  113. typedef struct {
  114.  
  115.     short                height;            /* paragraph height */
  116.  
  117.     Boolean                dirty;            /* one or more lines of the paragraph are dirty
  118.                                                 a) height of paragraph is invalid -and/or-
  119.                                                 b) start positions of lines are invalid
  120.                                         */
  121.  
  122.     short                start;            /* where this paragraph starts in the document */
  123.  
  124.     short                width;            /* paragraph width */
  125.     
  126.     long                    docOffset;            /* the document offset of the first glyph */
  127.     short                numText;            /* number of glyphs in this paragraph */
  128.     
  129.     short                numLines;
  130.     LineHan                lines;            /* lines that make up the paragraph */
  131.     
  132.     short                numRuns;            /* the runs that make up the paragraph */
  133.     NewRunHan            runs;
  134.     
  135.     Boolean                drawn;            /* this paragraph has been drawn and parts are uptodate */
  136.     
  137.     Boolean                reflow;            /* this paragraph needs to be reflowed */
  138.     
  139.     gxLayoutOptions        layoutOptions;        /* the layout options for this paragraph */
  140.     
  141. } ParaRec, * ParaPtr, ** ParaHan;
  142.  
  143. typedef struct {
  144.  
  145.     long                    startDocOffset;
  146.     long                    endDocOffset;
  147.     
  148.     Boolean                endOfLine;            /* the caret selection is at the end of a gxLine */
  149.     
  150.     short                startParaIndex;
  151.     short                startParaOffset;
  152.     short                endParaIndex;
  153.     short                endParaOffset;
  154.         
  155. } SelRec, * SelPtr, ** SelHan;
  156.  
  157. typedef struct {
  158.  
  159.     long                    numText;
  160.     short                numRuns;
  161.     NewRunHan            runs;
  162.     
  163. } ScrapRec, * ScrapPtr, ** ScrapHan;
  164.  
  165. typedef struct {
  166.     
  167.     Boolean                start;
  168.     
  169.     short                numStyles;
  170.     short                ** styles;
  171.  
  172.     short                numFonts;
  173.     gxFont                ** fonts;
  174.     
  175.     short                size;
  176.     
  177. } AttrRec, * AttrPtr, ** AttrHan;
  178.  
  179. typedef struct {
  180.     
  181.     long                    magic;                /* magic number for validity */
  182.     
  183.     long                    length;                /* length of overall document */
  184.     
  185.     Boolean                dirty;                /* the document is dirty
  186.                                                     a) length is invalid
  187.                                                     b) paragraph starts are invalid
  188.                                             */
  189.  
  190.     short                lineWidth;                /* width of a gxLine in the document  */
  191.     gxLayoutOptions        currentLayoutOptions;    /* the default layout options for new paragraphs */
  192.     
  193.     short                numStyles;            /* the styles that appear in the document */
  194.     StyleHan                styles;
  195.             
  196.     long                    numText;                /* number of glyphs in the document */
  197.  
  198.     short                numParagraphs;
  199.     ParaHan                paragraphs;            /* paragraphs that make up the document */
  200.         
  201.     SelRec                selection;                /* the current selection */
  202.     
  203.     Boolean                active;                /* is the document active */
  204.     
  205.     Rect                    viewRect;                /* the drawing area */
  206.     short                leftMargin;            /* the left margin */
  207.     short                rightMargin;            /* the right margin */
  208.     short                viewHeight;            /* the height of the view area */
  209.     
  210.     long                    top;                    /* the top position in the current view area */
  211.     long                    maxTop;                /* maximum top position */
  212.     
  213.     short                numCurrentStyles;        /* the styles, size and gxFont of the current selection */
  214.     short                ** currentStyles;
  215.     
  216.     short                currentSize;
  217.     
  218.     short                numCurrentFonts;
  219.     gxFont                ** currentFonts;
  220.     
  221.     short                emptyStyle;            /* the gxStyle used when the selection is empty */
  222.     
  223.     gxViewPort            docViewPort;            /* view port for document */
  224.     gxViewPort            offscreenPort;            /* offscreen view port */
  225.     gxViewDevice            offscreenDevice;
  226.     gxViewGroup            offscreenGroup;
  227.     Ptr                    offscreenBytes;
  228.     gxShape                offscreenBitmap;
  229.     
  230.     long                    pageTop;                /* the top page margin */
  231.     long                    pageBottom;            /* the bottom page margin */
  232.     long                    pageLeft;                /* the left page margin position */
  233.     long                    pageRight;                /* the right page margin position */
  234.     
  235.     ScrapRec                scrap;                /* the current document scrap */
  236.     
  237.     Boolean                drawn;                /* this document has been drawn and parts are up to date */
  238.     short                bottomClear;            /* from this gxPoint to the bottom is clear */
  239.  
  240.     long                    currentTime;            /* the time at the last idle call */
  241.     
  242.     GXEditUserErrorProc    errorProc;            /* user error posting routine */
  243.     long                    * errorProcRef;
  244.     
  245.     GXEditError            error;
  246.     GXEditError            stickyError;
  247.     
  248.     gxFontLanguage            currentLanguage;        /* language of all inserted text */
  249.     gxFontScript            currentScript;            /* script of inserted text */
  250.     gxFontPlatform            currentPlatform;
  251.     
  252.     Boolean                verticalText;            /* the text be displyed vertically */
  253.     
  254.     short                maxLineOffset;            /* the maxium line offset the user has selected */
  255.     
  256. } DocRec, * DocPtr, ** DocHan;
  257.  
  258. extern void         NewDoc(DocHan * doc, Rect * viewRect, gxViewPort docViewPort, short leftMargin, short rightMargin);
  259. extern void         DisposeDoc(DocHan doc);
  260.  
  261. extern void         DocSetSelection(DocPtr dp, long selStart, long selEnd);
  262. extern long        DocHitTest(DocPtr dp, Point pt);
  263.  
  264. extern void        DocClick(DocPtr dp, Point where, Boolean extend);
  265. extern void        DocScroll(DocPtr dp, short dv);
  266. extern void        DocSize(DocPtr dp, Rect * viewRect);
  267. extern long        DocSetTop(DocPtr dp, long top);
  268. extern long        DocGetTop(DocPtr dp);
  269. extern long        DocGetMaxTop(DocPtr dp);
  270. extern long        DocGetMaxTop(DocPtr dp);
  271. extern void        DocKey(DocPtr dp, char key);
  272. extern void         DocClear(DocPtr dp);
  273. extern void         DocInsert(DocPtr dp, void * text, short numText);
  274.  
  275. extern long        DocHeight(DocPtr dp);
  276.  
  277. extern void        DocSetTextFonts(DocPtr dp, short numFonts, gxFont * srcFonts, gxFont * dstFonts);
  278. extern void        DocGetTextFonts(DocPtr dp, short * numFonts, gxFont * fonts);
  279.  
  280. extern void        DocSetTextSize(DocPtr dp, short size);
  281. extern short        DocGetTextSize(DocPtr dp);
  282.  
  283. extern void        DocSetFeatures(DocPtr dp, gxFont fontId, short numFeatureGroups,
  284.                                     short * srcFeatureGroupSizes,
  285.                                     gxRunFeature ** srcFeatureGroups,
  286.                                     short * dstFeatureGroupSizes,
  287.                                     gxRunFeature ** dstFeatureGroups);
  288. extern void        DocGetFeatures(DocPtr dp, gxFont fontId, short * numFeatureGroupsPtr,
  289.                                     short *** featureGroupSizesPtr,
  290.                                     gxRunFeature **** featureGroupsPtr);
  291.  
  292. extern void        DocGetVariations(DocPtr dp, gxFont fontId, short * numInstancesPtr,
  293.                                         short *** instanceSizesPtr, gxFontVariation **** instancesPtr);
  294. extern void        DocSetVariations(DocPtr dp, gxFont fontId, short numVariations, gxFontVariation * variations);
  295.  
  296. extern void        DocGetSelectionStyles(DocPtr dp, short * numStyles, gxStyle * styles);
  297. extern void        DocSetSelectionStyles(DocPtr dp, gxStyle * toStyles);
  298.  
  299. extern void        DocSave(DocPtr dp, short fRefNum);
  300. extern void        DocOpen(DocHan * doc, Rect * viewRect, gxViewPort docViewPort, short fRefNum,
  301.                                                                     short leftMargin, short rightMargin);
  302.  
  303. extern void        DocPrint(DocPtr dp, gxJob printJob);
  304.  
  305. extern void        DocCut(DocPtr dp);
  306. extern void        DocCopy(DocPtr dp);
  307. extern void        DocPaste(DocPtr dp);
  308.  
  309. extern long        DocGetScrapLen(DocPtr dp);
  310. extern long        DocGetTextLen(DocPtr dp);
  311. extern long        DocGetSelectionLen(DocPtr dp);
  312.  
  313. extern void        DocGetRunControls(DocPtr dp, gxRunControls * runControls, gxRunControls *mask);
  314. extern void        DocSetRunControls(DocPtr dp, gxRunControls * runControls, gxRunControls *mask);
  315.  
  316. extern void        DocGetFontRunControls(DocPtr dp, gxFont fontID, gxRunControls * runControls, gxRunControls *mask);
  317.  
  318. extern void        DocGetLayoutOptions(DocPtr dp, gxLayoutOptions * options, gxLayoutOptions *mask);
  319. extern void        DocSetLayoutOptions(DocPtr dp, gxLayoutOptions * options, gxLayoutOptions *mask);
  320.  
  321. extern void        DocGetJustification(DocPtr dp, Boolean *setting);
  322. extern void        DocSetJustification(DocPtr dp, Boolean setting);
  323.  
  324. extern Boolean        DocIdle(DocPtr dp);
  325. extern void        DocUpdate(DocPtr dp, gxRectangle * updateRect);
  326.  
  327. extern void        DocSetMaxTop(DocPtr dp);
  328.  
  329. extern void        DocProof(DocPtr dp, GXEditProofPtr proof);
  330.  
  331. extern void        DocActivate(DocPtr dp, Boolean activate);
  332.  
  333. extern void        DocSetEncoding(DocPtr dp, gxFontPlatform platform, gxFontScript script, gxFontLanguage language);
  334.  
  335. extern void        DocSetVerticalText(DocPtr dp, Boolean enable);
  336. extern void        DocGetVerticalText(DocPtr dp, Boolean * enable);
  337.  
  338. extern void        DocGetSelectionEncoding(DocPtr dp, gxFontPlatform * platform,
  339.                                             gxFontScript * script, gxFontLanguage * language);
  340. extern void        DocSetSelectionEncoding(DocPtr dp, gxFontPlatform platform,
  341.                                             gxFontScript script, gxFontLanguage language);
  342.  
  343. Boolean            DocReflow(DocPtr dp);
  344.  
  345. #endif
  346.  
  347.  
  348.